package PolymorphicHomeworkTest5;
/*
圆形类
 */
public class Roundness extends Graph{
    private double radius;  //半径
    static final double PI = 3.14;
    public Roundness(){

    }
    public Roundness(String color,boolean fill,double radius){
        super(color,fill);
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    @Override
    public String toString() {
        return "圆形{" + "半径=" + radius + " 颜色="+super.getColor()
                +(super.isFill() ? " 填充":" 无填充")+'}';
    }

    public void getArea(){                     //重写父类的抽象方法，获取图形面积
        double area = this.radius * this.radius * PI;
        System.out.println("圆形面积是"+area);
    }

    public void getPerimeter(){
        double perimeter = 2 * this.radius * PI;
        System.out.println("圆形周长是"+perimeter);
    }

}
